
##############################################		
###need complete cases so subset below		

###reduced version
use.formula = as.formula(paste('ingroup.task ~ ',master.formula,sep = ''))
use.formula.out = as.formula(paste('outgroup.task ~ ',master.formula,sep = ''))

use.formula.reduced = as.formula(paste('ingroup.task ~ ',master.formula.reduced,sep = ''))

use.vars = c('ingroup.task','outgroup.task',master.use.vars)


################################################

use.dat.uo = dat.uo[,use.vars]
use.dat.uo = dat.uo[dat.uo$index.city != city ,use.vars]
use.dat.uo = use.dat.uo[complete.cases(use.dat.uo),]

reg.uo.task.reduced = lm(use.formula.reduced, data = use.dat.uo)
clustered.se = cl(use.dat.uo, reg.uo.task.reduced, use.dat.uo$index.city)
reg.uo.task.reduced$se = clustered.se

reg.uo.task = lm(use.formula, data = use.dat.uo)
clustered.se = cl(use.dat.uo, reg.uo.task, use.dat.uo$index.city)
reg.uo.task$se = clustered.se

use.dat.sec = dat.non.uo[,use.vars]
use.dat.sec = dat.non.uo[dat.non.uo$index.city != city ,use.vars]
use.dat.sec = use.dat.sec[complete.cases(use.dat.sec),]

reg.sec.task.reduced = lm(use.formula.reduced, data = use.dat.sec)
clustered.se = cl(use.dat.sec, reg.sec.task.reduced, use.dat.sec$index.city)
reg.sec.task.reduced$se = clustered.se

reg.sec.task = lm(use.formula, data = use.dat.sec)
clustered.se = cl(use.dat.sec, reg.sec.task, use.dat.sec$index.city)
reg.sec.task$se = clustered.se


